package xyz.scootaloo.oj.leetcode

import org.junit.Test
import xyz.scootaloo.common.TestDsl
import java.util.*

/**
 * @author flutterdash@qq.com
 * @since 2021/7/3 12:47
 */
class P217 : TestDsl {

    private fun containsDuplicate(nums: IntArray): Boolean {
        if (nums.size <= 1)
            return false

        Arrays.sort(nums)
        for (i in 1 until nums.size) {
            if (nums[i] == nums[i - 1])
                return true
        }
        return false
    }

    @Test
    fun test0() {
        containsDuplicate(intArrayOf(1, 2, 3, 1)) shouldBe true
        containsDuplicate(intArrayOf(1, 2, 3, 4)) shouldBe false
        containsDuplicate(intArrayOf(1, 1, 2, 3)) shouldBe true
    }

}
